package com.billsharing.server;

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


/**
 * Servlet implementation class AddFriend
 */
@WebServlet("/AddFriend")
public class AddFriend extends HttpServlet {
	private static final long serialVersionUID = 1L;

	/**
	 * @see HttpServlet#HttpServlet()
	 */

	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		
		PrintWriter out = response.getWriter();
	int	uid = Integer.parseInt(request.getParameter("uid"));
	String	friend_email = request.getParameter("fndemail");
	System.out.println("User in add friend"+uid);
	User user = new User(uid);
	
	boolean result = user.addFriend(friend_email);
	System.out.println(result);
	if(result)
	{
		out.print("true");
	}
	else
	{
		out.print("false");
	}
		
		
	}


}
